package com.aier.entrance.icsocket;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;
import org.apache.mina.filter.codec.demux.MessageEncoder;

public class ReplayMessageEncoder<T extends ReplayMessage> implements MessageEncoder<Object>{
    public ReplayMessageEncoder(){
    }
  
    @Override
    public void encode(IoSession arg0, Object message, ProtocolEncoderOutput out)
        throws Exception {
        IoBuffer buff = IoBuffer.allocate(((ReplayMessage) message).getLength());
        buff.setAutoExpand(true);       
        buff.put(((ReplayMessage) message).toBytes());
        buff.flip();
        out.write(buff);
    }


    
}
